package org.vy.app.ajax.service.metadata;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.vy.app.ajax.IService;
import org.vy.dal.dao.lookup.VyLookupReligionDAO;
import org.vy.dal.dao.lookup.VyLookupReligionDO;

public class ReligionMetaService implements IService<ReligionMetaResponse> {

	@Override
	public ReligionMetaResponse execute(Map<String, String> params, HttpServletRequest request) {
		ReligionMetaResponse rsp = new ReligionMetaResponse();
		try{
			VyLookupReligionDO dto = new VyLookupReligionDO();
			dto.setReligionCode("%");
			List<VyLookupReligionDO> religions = VyLookupReligionDAO.findByParam(dto);
			rsp.setReligion(getReligionMap(religions));
			
		}catch(Exception e){
			e.printStackTrace();
		}
		return rsp;
	}
	
	private Map<String, String> getReligionMap(List<VyLookupReligionDO> lst){
		Map<String, String> map = new HashMap<String, String>();
		for(VyLookupReligionDO rec : lst){
			map.put(rec.getReligionName(),rec.getReligionCode());
		}
		return map;
	}
}
